#!/bin/bash

#=======================================================================
# STDfilenameDTS
# File ID: STDuuidDTS
#
# [Description]
#
# Author: Øyvind A. Holm <sunny@sunbase.org>
# License: GNU General Public License version 2 or later.
#=======================================================================

topdir=/home/directory_that_does_not_exist-STDuuidDTS

# What the STDfilenameDTS script shall return, switch the values if the test 
# returns 0 for error and !0 for success.
good=0
bad=1

function cleangit {
    cd $topdir || { echo "STDfilenameDTS: $topdir: Cannot change directory, aborting." >&2; exit 150; }
    if [ ! -d .git/. ]; then
        echo "STDfilenameDTS: $topdir: Doesn’t contain a .git directory, aborting." >&2
        exit 150
    fi
    git clean -fxd
    git co -f
}

function inittest {
    : Things like ./configure and make goes here
}

function runtest {
    : The actual test goes here and should return !$good on error
}

cleangit
cd $topdir
inittest
runtest || { cleangit; echo STDfilenameDTS: bad, returns $bad; exit $bad; }
cleangit
echo STDfilenameDTS: good, returns $good
exit $good
